<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
      #parsent {
        width: 500px;
        height: 500px;
        padding: 20px;
        border: 2px solid red;
      }
      #son {
        width: 200px;
        height: 200px;
        padding: 5px;
        border: 1px solid green;
      }
    </style>
  </head>
  <body>
    <div id="parsent">
      <div id="son">haha</div>
    </div>
    <script>
      //offset 偏移量
      var box = document.getElementById('son');
      //为只读属性，它返回当前元素相对于其 最近的定位的祖先 元素的顶部内边距的距离 |
      console.log(box.offsetTop);
      console.log(box.offsetLeft);
      //返回自身高度大小，`height+padding*2+border*2`， 含滚动条 |
      console.log(box.offsetHeight) 
      //返回自身宽度大小，width+padding*2 +padding*2,含滚动条
      console.log(box.offsetWidth);

     //client 元素可视区的相关信息
      //返回元素上边框大小
      console.log(box.clientTop);
      console.log(box.clientLeft);
       // 可视区宽度 = 自身width+ padding*2
      console.log(box.clientWidth)
      console.log(box.clientHeight)

      console.log(document.documentElement.clientWidth)

    
    </script>
  </body>
</html>
